package com.ambulance.project.biz.controller.manager;

import com.ambulance.common.utils.poi.ExcelUtil;
import com.ambulance.framework.aspectj.lang.annotation.Log;
import com.ambulance.framework.aspectj.lang.enums.BusinessType;
import com.ambulance.framework.web.controller.BaseController;
import com.ambulance.framework.web.domain.AjaxResult;
import com.ambulance.framework.web.page.TableDataInfo;
import com.ambulance.project.manager.domain.BizDispatchdevice;
import com.ambulance.project.manager.service.IBizDispatchdeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 调度车载设备记录信息Controller
 *
 * @author zr
 * @date 2020-07-08
 */
@RestController
@RequestMapping("/manager/dispatchDevice")
public class BizDispatchdeviceController extends BaseController {
    @Autowired
    private IBizDispatchdeviceService bizDispatchdeviceService;

    /**
     * 查询调度车载设备记录信息列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchDevice:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDispatchdevice bizDispatchdevice) {
        startPage();
        List<BizDispatchdevice> list = bizDispatchdeviceService.selectBizDispatchdeviceList(bizDispatchdevice);
        return getDataTable(list);
    }

    /**
     * 导出调度车载设备记录信息列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchDevice:export')")
    @Log(title = "调度车载设备记录信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizDispatchdevice bizDispatchdevice) {
        List<BizDispatchdevice> list = bizDispatchdeviceService.selectBizDispatchdeviceList(bizDispatchdevice);
        ExcelUtil<BizDispatchdevice> util = new ExcelUtil<BizDispatchdevice>(BizDispatchdevice.class);
        return util.exportExcel(list, "dispatchDevice");
    }

    /**
     * 获取调度车载设备记录信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchDevice:query')")
    @GetMapping(value = "/{deviceRecordID}")
    public AjaxResult getInfo(@PathVariable("deviceRecordID") Long deviceRecordID) {
        return AjaxResult.success(bizDispatchdeviceService.selectBizDispatchdeviceById(deviceRecordID));
    }


    @GetMapping(value = "dispatch/{dispatchCaseID}")
    public AjaxResult getDispatchInfo(@PathVariable("dispatchCaseID") Long dispatchCaseID) {
        return AjaxResult.success(bizDispatchdeviceService.selectBizDispatchdeviceById2(dispatchCaseID));
    }

    /**
     * 新增调度车载设备记录信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchDevice:add')")
    @Log(title = "调度车载设备记录信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizDispatchdevice bizDispatchdevice) {
        return toAjax(bizDispatchdeviceService.insertBizDispatchdevice(bizDispatchdevice));
    }

    /**
     * 修改调度车载设备记录信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchDevice:edit')")
    @Log(title = "调度车载设备记录信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizDispatchdevice bizDispatchdevice) {
        return toAjax(bizDispatchdeviceService.updateBizDispatchdevice(bizDispatchdevice));
    }

    /**
     * 删除调度车载设备记录信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatchDevice:remove')")
    @Log(title = "调度车载设备记录信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{deviceRecordIDs}")
    public AjaxResult remove(@PathVariable Long[] deviceRecordIDs) {
        return toAjax(bizDispatchdeviceService.deleteBizDispatchdeviceByIds(deviceRecordIDs));
    }
}
